package com.spring.zhz;

import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.Resource;

@Data
public class People {
    //如果显示的定义了Autowired的required属性为false，说明这个对象可以为null，否则不允许为空
    @Resource(name = "cat1")
    private Cat cat;
    @Autowired
    private Dog dog;
    private String name;
    @Override
    public String toString() {
        return "People{" +
                "cat=" + cat +
                ", dog=" + dog +
                ", name='" + name + '\'' +
                '}';
    }
}

class Cat {

}

class Dog {

}
